package com.qg.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.qg.dto.ReturnResult;
import com.qg.dto.ReturnResultUtils;
import com.qg.pojo.QgGoods;
import com.qg.pojo.QgUser;
import com.qg.service.LocalGoodsService;
import com.qg.util.EmptyUtils;
import com.qg.vo.GoodsVo;
import com.qg.vo.QgUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Controller
@RequestMapping(value = "/api")
public class QgGoodsController {
    /**
     * 查询
     * @param phone
     * @param password-
     * @return
     */
    @Resource
    private LocalGoodsService localGoodsService;

    @RequestMapping(value = "/getGoods",method = RequestMethod.POST)
    @ResponseBody
    public GoodsVo getGoodsById(String id) throws Exception {
        GoodsVo goodsVo=localGoodsService.queryGoodsById(id);
        if (EmptyUtils.isEmpty(goodsVo)){
            return null;
        }
        return goodsVo;
    }
    @RequestMapping(value = "/getGoodsMessage")
    @ResponseBody
    public ReturnResult getGoods(String token,String goodsId) throws Exception{
        return localGoodsService.getGoods(token,goodsId);
    }
}
